package leetcode.code1288;

import java.util.Arrays;

public class Solution {
	public int removeCoveredIntervals(int[][] intervals) {
		Arrays.sort(intervals, (a, b) -> a[0] == b[0] ? b[1] - a[1] : a[0] - b[0]);
		int ans = 0, range = 0;
		for (int i = 0; i < intervals.length; i++) {
			int[] ints = intervals[i];
			int b = ints[1];
			if (b > range) {
				ans += 1;
				range = b;
			}
		}
		return ans;
	}
}
